package com.boluo.web.controller.businessManagement;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.boluo.businessManagement.dto.BusMentGoodsDTO;
import com.boluo.businessManagement.vo.BusMentGoodVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.boluo.common.annotation.Log;
import com.boluo.common.core.controller.BaseController;
import com.boluo.common.core.domain.AjaxResult;
import com.boluo.common.enums.BusinessType;
import com.boluo.businessManagement.domain.BusMentGoods;
import com.boluo.businessManagement.service.IBusMentGoodsService;
import com.boluo.common.utils.poi.ExcelUtil;
import com.boluo.common.core.page.TableDataInfo;

/**
 * 物品信息Controller
 * 
 * @author boluo
 * @date 2023-05-02
 */
@RestController
@RequestMapping("/businessManagement/goods")
public class BusMentGoodsController extends BaseController
{
    @Autowired
    private IBusMentGoodsService busMentGoodsService;

    /**
     * 查询物品信息列表
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:goods:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusMentGoodsDTO busMentGoodsDTO)
    {
        startPage();
        List<BusMentGoodVO> list = busMentGoodsService.selectBusMentGoodsList(busMentGoodsDTO);
        return getDataTable(list);
    }



    /**
     * 获取物品信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:goods:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(busMentGoodsService.selectBusMentGoodsById(id));
    }

    /**
     * 新增物品信息
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:goods:add')")
    @Log(title = "物品信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusMentGoods busMentGoods)
    {
        return toAjax(busMentGoodsService.insertBusMentGoods(busMentGoods));
    }

    /**
     * 修改物品信息
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:goods:edit')")
    @Log(title = "物品信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusMentGoods busMentGoods)
    {
        return toAjax(busMentGoodsService.updateBusMentGoods(busMentGoods));
    }


    /**
     * 删除物品信息
     */
    @PreAuthorize("@ss.hasPermi('businessManagement:goods:remove')")
    @Log(title = "物品信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(busMentGoodsService.deleteBusMentGoodsById(id));
    }
}
